from math import sin, pi
from matplotlib import pyplot as plt
from typing import Callable, Iterable


def _draw(func: Callable[[float], float], x: Iterable[float]):
    for v in x:
        plt.scatter(v, func(v), marker="*")


plt.xlim(-4, 4)
plt.ylim(-1.2, 1.2)

plt.plot([-4, 4], [0, 0])
plt.plot([0, 0], [-1.2, 1.2])

_draw(lambda x: sin(x), (i / 10 for i in range(int(-pi * 10), int(pi * 10) + 1, 1)))

plt.text(-3.33, -0.1, "-pi")
plt.text(3.2, -0.1, "pi")
plt.text(0.2, -0.1, "0")
plt.text(3.8, -0.1, "X")
plt.text(0.1, 1.1, "Y")

plt.title("Sin函数曲线")

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False
plt.show()
